﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPF_MVVM_Simple.Model;
using WPF_MVVM_Simple.ViewModel;

namespace WPF_MVVM_Simple
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public MainWindow(MainViewModel mainViewModel)
        {
            InitializeComponent();

            if (mainViewModel != null)
            {
                DataContext = mainViewModel;
            }
        }

        ///// <summary>
        ///// 获取作者信息Click
        ///// 数据流向：Model-> ViewModel-> View
        ///// </summary>
        //private void Button_Click(object sender, RoutedEventArgs e)
        //{
        //    // Model ->ViewModel
        //    UserModel userModel = new UserModel()
        //    {
        //        ID = Guid.NewGuid().ToString("N"),
        //        Name = "Bili执笔小白",
        //        Email = "2806933146@qq.com"
        //    };

        //    MainViewModel mainViewModel = new MainViewModel()
        //    {
        //        Name = userModel.Name,
        //        Email = userModel.Email
        //    };

        //    // ViewModel ->View
        //    this.DataContext = mainViewModel;
        //}

        /// <summary>
        /// 和作者打招呼Click
        /// 数据流向：View-> ViewModel-> View
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void Button1_Click(object sender, RoutedEventArgs e)
        //{
        //    if (this.DataContext is MainViewModel mainViewModel)
        //    {
        //        mainViewModel.Log = "你好！" + mainViewModel.Name;
        //    }
        //}
    }
}